package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.JieSuanBean;
import com.lwj.liwanjia.bean.ToJieSuanBean;
import com.lwj.liwanjia.impl.JieSuanView;
import com.lwj.liwanjia.model.JieSuanModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/3.
 */

public class JieSuanPresenter {
    private JieSuanModel jieSuanModel;
    private JieSuanView jieSuanView;

    public JieSuanPresenter(JieSuanView jieSuanView) {
        this.jieSuanView = jieSuanView;
        jieSuanModel = new JieSuanModel();
    }

    public void toJieSuan(String token, ToJieSuanBean toJieSuanBean) {
        if (jieSuanView != null) {
            jieSuanModel.toJieSuan(token, toJieSuanBean, new Subscriber<JieSuanBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    jieSuanView.showError((Exception) e);
                }

                @Override
                public void onNext(JieSuanBean jieSuanBean) {
                    jieSuanView.toJieSuan(jieSuanBean);
                }
            });
        }
    }
}
